<?php

/**
 * KTDFaction form.
 *
 * @package    s-test
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class KTDFactionForm extends BaseKTDFactionForm
{
  public function configure()
  {
  }
}

class BackendKTDFactionForm extends KTDFactionForm{
  public function configure()
  {
     unset($this['created_at'], $this['updated_at']);
     $this->setWidgets(array(
          'name'        =>  new sfWidgetFormInput(array('label' => 'Nom de la faction')),
          'logo'        =>  new sfWidgetFormInputFileEditable(array(
               'label' => 'Logo de la faction',
               'is_image' => true,
               'file_src' => '/uploads/images/factions/'.$this->getObject()->getLogo(),
               'edit_mode'=> !$this->isNew(),
               'template'  => '%file%<br />%input%<br/>%delete% %delete_label%')),
          'description' =>  new sfWidgetFormTextarea(),
          'member_id'      =>  new sfWidgetFormSelectMany(array('choices' => KTDCharacter::getCharactersByIdPseudo(), 'translate_choices'=>true), array('style'=> 'height: 300px'))
      ));
     
     $this->validatorSchema['name'] = new sfValidatorString(array('required'=>true));
     $this->validatorSchema['description'] = new sfValidatorString(array("required"=>false));
     $this->validatorSchema['logo'] = new sfValidatorFile(array(
        'required'   => false,
        'path'       => sfConfig::get('sf_upload_dir').'/images/factions',
        'mime_types' => 'web_images',
       ));
     $this->validatorSchema['logo_delete'] = new sfValidatorPass();

     $this->widgetSchema->setNameFormat("ktd_faction[%s]");
  }
}